#!/usr/bin/env python
# -*- coding: utf-8 -*-

from abc import ABCMeta, abstractmethod
from typing import Any

from web.domain.responsibility_chain_dto import ResponsibilityChainDto


class AbstractStep(metaclass=ABCMeta):
    """
    抽象步骤类
    """

    def __init__(self, successor=None):
        self._successor = successor

    def set_successor(self, successor):
        """
        设置下一步的对象
        """

        self._successor = successor

    def next(self, responsibility_chain_dto: ResponsibilityChainDto = None):
        if self._successor:
            self._successor.exec(responsibility_chain_dto)

    @abstractmethod
    def exec(self, responsibility_chain_dto: ResponsibilityChainDto = None) -> Any:
        """
        执行
        """

        pass
